{% extends 'activity/activity-layout.html.twig' %}
{% do script(['libs/ltc-sdk-client.js', 'libs/es-ckeditor/ckeditor.js','libs/jquery-sortable.js','homeworkactivity/js/create/index.js'], 300) %}
{% block  activity_step %}
  <style>
    .form-error-message {
      min-height: 20px;
      line-height: 20px;
      margin-bottom: 0;
      color: #fe4040;
    }

    .dropdown-toggle {
      background: #fff;
    }

    .score-tip {
      position: absolute;
      top: 17px;
      left: 198px;
      font-size: 16px;
      font-weight: 500;
    }

    .score-tip-par {
      position: relative;
    }
  </style>
  <div class="tab-pane js-course-tasks-pane active js-step2-view">
    <form class="form-horizontal" id="step2-form">
      <div class="form-group">
        <div class="col-sm-2 control-label">
          <label for="title" class="control-label-required">{{ 'course.plan_task.activity_manage.title_name'|trans }}</label>
        </div>
        <div class="col-sm-10">
          <input id="title" class="form-control" type="text" name="title" value="{{ activity.title|default('') }}">
          <div class="help-block">{{ 'course.plan_task.activity_manage.help_block'|trans }}</div>
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-2 control-label"><label for="homework-about-field" class="control-label-required">{{ 'course.plan_task.activity_manage.homework.info'|trans }}</label>
        </div>
        <div class="col-sm-10 controls">
          <textarea name="description" rows="10" id="homework-about-field" class="form-control"
                    data-image-upload-url="{{ path('editor_upload', {token:upload_token('course')}) }}"
                    data-image-download-url="{{ path('editor_download', {token:upload_token('course')}) }}">{{ activity.ext.assessment.description|default('') }}</textarea>
        </div>
      </div>
      {% if activity.canEdit|default(0) or (activity.ext is defined and activity.ext.has_published is defined and activity.ext.has_published == 0)  %}

        {% if questions is not defined and activity.ext is defined and activity.ext is not empty %}
          {% set questionBank = activity.ext.questionBank %}
          {% set categories = activity.ext.categories %}
          {% set questions = activity.ext.questions %}
        {% endif %}
      <div class="form-group">
        <div class="col-sm-2 control-label">
          <label for="homework-about-field" class="control-label-required">{{ 'course.plan_task.activity_manage.homework.choose_question'|trans }}</label>
        </div>
        <div class="col-sm-8">
          <a id="picker_homework_items"
             data-url="{{ path('course_set_manage_homework_question_picker',{id:activity.fromCourseSetId,targetType:'homework'}) }}"
             data-pick-url="{{ path('course_set_manage_homework_question_picked', {courseSetId:activity.fromCourseSetId}) }}"
             class="btn btn-info btn-sm js-pick-modal" data-role="pick-item">
            <i class="es-icon es-icon-anonymous-iconfont"></i>
            {{ 'course.plan_task.activity_manage.homework.choose_question'|trans }}
          </a>
          <input type="hidden" name="questionLength" value="{% if questions|default(null) %} questionItems.lenght {% endif %}">
        </div>
      </div>
        <p class="help-block color-warning pull-right" style="margin-top: -25px">{{ 'course.homework.score.tip'|trans }}</p>
      <div class="form-group">
        <div class="col-sm-12" style="margin-left: 50px; padding-right: 60px;">
          <table class="table" id="question-table">
            <thead>
            <tr>
              <th width="5%"><input type="checkbox" data-role="batch-select"></th>
              <th width="30%">{{ 'course.testpaper_manage.question.stem'|trans }}</th>
              <th width="15%">{{ 'course.testpaper_manage.question.type'|trans }}</th>
              <th width="30">{{ 'course.question_manage.manage.score'|trans }}
                <span class="link-medium es-icon es-icon-help ml5"
            data-container="body" data-toggle="popover" data-trigger="hover" data-placement="top"
            data-content="{{ 'course.homework.score_title.tips'|trans()|raw}}">
      </span>
              </th>
              <th width="10%">{{ 'course.testpaper_manage.question.difficulty'|trans }}</th>
              <th width="10%">{{ 'course.testpaper_manage.question.operation'|trans }}</th>
            </tr>
            </thead>
            <tbody class="js-homework-table" id="question-table-tbody">
            {% if questions|default(null) %}
              {% for question in questions %}
                {% include 'homework/manage/question-picked-tr.html.twig' %}
              {% endfor %}
            {% endif %}
            </tbody>
          </table>
          <div class="js-cached-question hidden"></div>
          <input type="hidden" class="js-origin-bank">
          <input type="hidden" class="js-current-bank" value="{{ questionBank.id|default() }}">
          <input type="hidden" class="js-homework-scores-input" name="scores">
          <div class="mbl">
            <label class="checkbox-inline"><input type="checkbox" data-role="batch-select"> {{ 'course.testpaper_manage.question.select_all'|trans }}
            </label>
            <button type="button" class="btn btn-default btn-sm mlm" data-role="batch-delete-btn" data-name="{{ 'course.testpaper_manage.question.content'|trans }}">{{ 'form.btn.remove'|trans }}</button>
          </div>
          <span class="color-danger js-help-redmine"></span>
          <p class="js-subjective-remask" data-type="homework"></p>
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-8" style="margin-left: 50px">
          <p class="help-block color-warning">{{ 'course.plan_task.activity_manage.homework.save_tips'|trans }}</p>
        </div>
      </div>
      {% endif %}
      {% if activity.ext is defined and ((activity.ext.has_published is defined and activity.ext.has_published == 2) or (activity.ext.isQuote is defined and activity.ext.isQuote)) %}
      <div class="form-group">
        <div class="col-sm-8 col-sm-offset-2">
          <p class="help-block color-danger">{{ 'course.plan_task.activity_manage.homework.can_not_edit_tips'|trans }}</p>
        </div>
      </div>
      {% endif %}
    </form>
  </div>
{% endblock %}